package com.tpod.taxi.service;

import java.util.HashMap;

import tpod.network.HTTPCachePolicy;
import tpod.network.HTTPRequest;
import tpod.utils.debug.Debug;

import kds.business.BaseService;
import kds.business.BusinessDelegate;

import com.tpod.taxi.APIAccessAddressBuilder;
import com.tpod.taxi.TaxiApplication;
import com.tpod.taxi.entity.Taxi;

public class TaxiService extends BaseService<Taxi> {

	public TaxiService() {
		businessReponse = new TaxiReponse();
	}

	public void getListTaxi(BusinessDelegate<Taxi> delegate, String city,
			boolean onlineMode) {
		Debug.info("Load List Taxi datas in city id:" + city + " Online Mode: "
				+ onlineMode);
		this.addBusinessDelegate(delegate);

		HashMap<String, String> params = new HashMap<String, String>();
		params.put("city", city);
		APIAccessAddressBuilder builder = new APIAccessAddressBuilder(
				TaxiApplication.HOST_API, "taxi", "default", params);

		HTTPRequest request = new HTTPRequest(builder.getURL(), this);
		request.setCachePolicy(onlineMode ? HTTPCachePolicy.SYNC_LOCAL
				: HTTPCachePolicy.LOCAL);
		request.send();
	}

}
